function iterate (arr) {
  let index = 0
  return {
    next: () => {
      if (index < arr.length) {
        return { value: arr[index++], isEnd: false }
      } else {
        return { value: arr[index], isEnd: true }
      }
    }
  }
}

const it = iterate(['吃饭', '睡觉', '打豆豆'])
console.log(it.next())
console.log(it.next())
console.log(it.next())
console.log(it.next())
console.log(it.next())
